cmake_minimum_required(VERSION 3.10.2)

###########################################################
#### Project configuration                             ####
###########################################################

project(MMMConverterGUI)

###########################################################
#### Source configuration                              ####
###########################################################

set(SOURCE_FILES
    ${PROJECT_SOURCE_DIR}/MMMConverterGUIMain.cpp
    ${PROJECT_SOURCE_DIR}/MMMConverterGUIWindow.cpp
    #${PROJECT_SOURCE_DIR}/MMMConverterGUI.cpp
    ${PROJECT_SOURCE_DIR}/../common/ConverterApplicationBaseConfiguration.cpp
    ${PROJECT_SOURCE_DIR}/../common/ConverterApplicationHelper.cpp
)

set(HEADER_FILES
    ${PROJECT_SOURCE_DIR}/MMMConverterGUIWindow.h
    #${PROJECT_SOURCE_DIR}/MMMConverterGUI.h
    ${PROJECT_SOURCE_DIR}/MMMConverterGuiConfiguration.h
    ${PROJECT_SOURCE_DIR}/../common/ConverterApplicationBaseConfiguration.h
    ${PROJECT_SOURCE_DIR}/../common/ConverterApplicationHelper.h
)

set(MOC_FILES
    ${PROJECT_SOURCE_DIR}/MMMConverterGUIWindow.h
)

set(UI_FILES
    ${PROJECT_SOURCE_DIR}/MMMConverterGUI.ui
)

###########################################################
#### CMake package configuration                       ####
###########################################################

find_package(MMMCore REQUIRED)
set(EXTERNAL_LIBRARY_DIRS ${EXTERNAL_LIBRARY_DIRS} MMMCore)

find_package(Simox REQUIRED)

set(EXTERNAL_LIBRARY_DIRS ${EXTERNAL_LIBRARY_DIRS} MMMSimoxTools)

###########################################################
#### Project build configuration                       ####
###########################################################

# create the executable
SimoxQtApplication(${PROJECT_NAME} "${SOURCE_FILES}" "${HEADER_FILES}" "${MOC_FILES}" "${UI_FILES}")

target_link_libraries(${PROJECT_NAME}  PRIVATE ${EXTERNAL_LIBRARY_DIRS} dl)

set(MMMConverterGUI_BASE_DIR ${PROJECT_SOURCE_DIR} CACHE INTERNAL "")
add_definitions(-DMMMConverterGUI_BASE_DIR="${MMMConverterGUI_BASE_DIR}" -D_SCL_SECURE_NO_WARNINGS)

install(
    TARGETS ${PROJECT_NAME}
    EXPORT "${CMAKE_PROJECT_NAME}Targets"
    #LIBRARY DESTINATION lib
    #ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin
    #INCLUDES DESTINATION include
    COMPONENT bin
)

#add_subdirectory(tests) # TODO: fix tests
add_definitions(-DMMMTools_LIB_DIR="${MMMTools_LIB_DIR}")

###########################################################
#### Compiler configuration                            ####
###########################################################

include_directories(${EXTERNAL_INCLUDE_DIRS})
link_directories(${EXTERNAL_LIBRARY_DIRS})
add_definitions(${EXTERNAL_LIBRARY_FLAGS})